(async  function(){
    // 引入数据库模块
    const mysql = require('mysql2/promise')

    // 使用连接数据库
    const connection = await mysql.createConnection({
        host: '127.0.0.1',
        user: 'root',
        password: '',
        database: 'test'
    });

    // 执行sql语句
    let arr = await connection.query('SELECT * FROM users');
    // 结构赋值
    let [users] = arr;

    console.log(users)

})()